﻿Imports BUS
Imports DTO
Public Class FormSuaBan
    Public _flag As Integer = 0
    Dim _banBUS As New BanBUS()
    Dim _listBan As New List(Of BanDTO)
    Private Sub FormSuaBan_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        LoadBan()

    End Sub
    Public Sub LoadBan()
        _listBan = _banBUS.LayDanhSachBanBUS()
        For Each BanDTO As BanDTO In _listBan
            cbMaBan.Items.Add(BanDTO.MaBan)
        Next
    End Sub

    Public Sub CheckRbBan(ByVal _loai)
        If (_loai = 1) Then
            rbBanThuong.Checked = True
        End If
        If (_loai = 2) Then
            rbBanBidaLo.Checked = True
        End If
        If (_loai = 3) Then
            rbBanCarom.Checked = True
        End If
    End Sub
    Private Sub cbMaBan_SelectionChangeCommitted(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbMaBan.SelectionChangeCommitted
        For i = 0 To _listBan.Count - 1
            If (cbMaBan.SelectedItem.ToString() = _listBan(i).MaBan) Then
                CheckRbBan(_listBan(i).Loai)
            End If
        Next
    End Sub

    Private Sub btnCapNhat_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCapNhat.Click
        If (cbMaBan.SelectedIndex = -1) Then
            MessageBox.Show("Chọn mã bàn")
        Else
            _flag = 1
            Me.Close()
        End If
    End Sub

    Private Sub btnHuy_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnHuy.Click
        Me.Close()
    End Sub
End Class